package technicalservices.error;

import java.util.ArrayList;
import java.util.List;

/**
 * ErrorHandler class
 */
public class ErrorHandler {

	private static ErrorHandler errorHandler;
	private List<IErrorListener> errorListeners;

	private ErrorHandler() {
		errorListeners = new ArrayList<IErrorListener>();
		errorListeners.add(new ErrorLogger());
		errorListeners.add(new ErrorDialog());
	}

	public static synchronized ErrorHandler getInstance() {
		if (errorHandler == null) {
			errorHandler = new ErrorHandler();
		}

		return errorHandler;
	}

	public void showError(String error) {
		for (IErrorListener errorListener : errorListeners) {
			errorListener.showError(error);
		}
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		throw new CloneNotSupportedException();
	}

}
